package edu.ncsu.csc326.coffeemaker;

import junit.framework.TestCase;

/*
 * Errors found:
 * 	Unhandled exceptions at edit and add
 */

/**
 * 
 * @author Filipe Betzel
 *
 * Unit tests for RecipeBook class.
 */
public class RecipeBookTest extends TestCase {
	
	private CoffeeMaker cm;
	private Recipe r1;
	private Recipe r2;
	private Recipe r3;
	private Recipe r4;
	private Recipe r5;
	private RecipeBook RB;

	protected void setUp() throws Exception {
		cm = new CoffeeMaker();
		
		RB = new RecipeBook();
		
		//Set up for r1
		r1 = new Recipe();
		r1.setName("Coffee");
		r1.setAmtChocolate("0");
		r1.setAmtCoffee("3");
		r1.setAmtMilk("1");
		r1.setAmtSugar("1");
		r1.setPrice("50");
		
		//Set up for r2
		r2 = new Recipe();
		r2.setName("Mocha");
		r2.setAmtChocolate("20");
		r2.setAmtCoffee("3");
		r2.setAmtMilk("1");
		r2.setAmtSugar("1");
		r2.setPrice("75");
		
		//Set up for r3
		r3 = new Recipe();
		r3.setName("Latte");
		r3.setAmtChocolate("0");
		r3.setAmtCoffee("3");
		r3.setAmtMilk("3");
		r3.setAmtSugar("1");
		r3.setPrice("100");
		
		//Set up for r4
		r4 = new Recipe();
		r4.setName("Hot Chocolate");
		r4.setAmtChocolate("4");
		r4.setAmtCoffee("0");
		r4.setAmtMilk("1");
		r4.setAmtSugar("1");
		r4.setPrice("65");
		
		//Set up for r5
		r5 = new Recipe();
		r5.setName("French Vanilla");
		r5.setAmtChocolate("1");
		r5.setAmtCoffee("3");
		r5.setAmtMilk("2");
		r5.setAmtSugar("3");
		r5.setPrice("100");
				
		super.setUp();
	}
	

	////////////////////////
	//getRecipes()
	////////////////////////
	
	public void testGetRecipes() {
		RB.getRecipes();
	}
	
	
	////////////////////////
	//addRecipe(Recipe)
	////////////////////////
	
	public void testAddRecipeTrue() {
		assertTrue(RB.addRecipe(r1));
		assertTrue(RB.addRecipe(r2));
		assertTrue(RB.addRecipe(r3));
		assertTrue(RB.addRecipe(r4));
	}
	
	public void testAddRecipeFalse() {
		assertTrue(RB.addRecipe(r1));
		assertFalse(RB.addRecipe(r1));
	}
	
	public void testAddRecipeTooMany() {
		assertTrue(RB.addRecipe(r1));
		assertTrue(RB.addRecipe(r2));
		assertTrue(RB.addRecipe(r3));
		assertTrue(RB.addRecipe(r4));
		assertFalse(RB.addRecipe(r5));
	}
	
	////////////////////////
	//deleteRecipe(int)
	////////////////////////
	
	public void testDeleteRecipe() {
		assertTrue(RB.addRecipe(r1));
		assertEquals(RB.deleteRecipe(0), r1.getName());
	}
	
	public void testDeleteRecipeNotExist() {
		assertEquals(RB.deleteRecipe(0), null);
	}
	
	public void testDeleteNegative() {
		RB.addRecipe(r1);
		assertEquals(RB.deleteRecipe(-1), null);
	}
	
	////////////////////////
	//editRecipe(int, Recipe)
	////////////////////////
	
	public void testEditRecipe() {
		assertTrue(RB.addRecipe(r1));
		assertEquals(RB.editRecipe(0, r2), r1.getName());
	}
	
	public void testEditRecipeNotExist() {
		assertEquals(RB.editRecipe(0, r2), null);
	}
	
	public void testEditNegative() {
		assertTrue(RB.addRecipe(r1));
		assertEquals(RB.editRecipe(-1, r1), null);
	}
	
}

